<?php
 

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
        $this->session = new Zend_Session_Namespace('test');
    }

    public function indexAction()
    {
        if (!isset($this->session->actualTest)) {
            // initializes the session data

            if (isset($this->session->ok_responses)) {
                unset($this->session->ok_responses);
            }

            if (isset($this->session->fail_responses)) {
                unset($this->session->fail_responses);
            }

            if (isset($this->session->tries)) {
                unset($this->session->tries);
            }
        

            $level = new Application_Model_LevelMapper();
            $levels = $level->fetchAll();

            $first_level = $levels[0];

            $testMapper = new Application_Model_TestMapper();
            $tests = $testMapper->fetchByLevel($first_level->getId());

            $first_test = $tests[0];

            return $this->_helper->redirector->gotoUrl('/user-tests/do-test/?test_id='.$first_test->getId());
        }
        
    }


}

